package com.yimu.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yimu.common.annotation.Log;
import com.yimu.common.enums.BusinessType;
import com.yimu.system.domain.SignalStrengthLog;
import com.yimu.system.service.ISignalStrengthLogService;
import com.yimu.common.core.controller.BaseController;
import com.yimu.common.core.domain.AjaxResult;
import com.yimu.common.utils.poi.ExcelUtil;
import com.yimu.common.core.page.TableDataInfo;

/**
 * 设备信号强度日志Controller
 * 
 * @author Christine
 * @date 2020-08-26
 */
@Controller
@RequestMapping("/system/signalstrengthlog")
public class SignalStrengthLogController extends BaseController
{
    private String prefix = "system/signalstrengthlog";

    @Autowired
    private ISignalStrengthLogService signalStrengthLogService;

    @RequiresPermissions("system:signalstrengthlog:view")
    @GetMapping()
    public String signalstrengthlog()
    {
        return prefix + "/signalstrengthlog";
    }

    /**
     * 查询设备信号强度日志列表
     */
    @RequiresPermissions("system:signalstrengthlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SignalStrengthLog signalStrengthLog)
    {
        startPage();
        List<SignalStrengthLog> list = signalStrengthLogService.selectSignalStrengthLogList(signalStrengthLog);
        return getDataTable(list);
    }

    /**
     * 导出设备信号强度日志列表
     */
    @RequiresPermissions("system:signalstrengthlog:export")
    @Log(title = "设备信号强度日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SignalStrengthLog signalStrengthLog)
    {
        List<SignalStrengthLog> list = signalStrengthLogService.selectSignalStrengthLogList(signalStrengthLog);
        ExcelUtil<SignalStrengthLog> util = new ExcelUtil<SignalStrengthLog>(SignalStrengthLog.class);
        return util.exportExcel(list, "signalstrengthlog");
    }

    /**
     * 新增设备信号强度日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存设备信号强度日志
     */
    @RequiresPermissions("system:signalstrengthlog:add")
    @Log(title = "设备信号强度日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SignalStrengthLog signalStrengthLog)
    {
        return toAjax(signalStrengthLogService.insertSignalStrengthLog(signalStrengthLog));
    }

    /**
     * 修改设备信号强度日志
     */
    @GetMapping("/edit/{Id}")
    public String edit(@PathVariable("Id") Long Id, ModelMap mmap)
    {
        SignalStrengthLog signalStrengthLog = signalStrengthLogService.selectSignalStrengthLogById(Id);
        mmap.put("signalStrengthLog", signalStrengthLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存设备信号强度日志
     */
    @RequiresPermissions("system:signalstrengthlog:edit")
    @Log(title = "设备信号强度日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SignalStrengthLog signalStrengthLog)
    {
        return toAjax(signalStrengthLogService.updateSignalStrengthLog(signalStrengthLog));
    }

    /**
     * 删除设备信号强度日志
     */
    @RequiresPermissions("system:signalstrengthlog:remove")
    @Log(title = "设备信号强度日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(signalStrengthLogService.deleteSignalStrengthLogByIds(ids));
    }
}
